import React, { Component } from 'react'

export default class Test extends Component {
  state = {
    xxx: 1,
  }
  render() {
    return <div id="test">Test,{this.state.xxx}</div>
  }
  // 当前组件的状态值由外界传入的props决定
  static getDerivedStateFromProps(props, state) {
    console.log(props, state)
    // props是外界传入的数据
    //state 是当前组件的状态
    return {
      xxx: props.c,
    }
  }
}
